// 数字格式化
export const formatNumber = (num) => {
  if (num >= 10000) {
    return (num / 10000).toFixed(1) + '万'
  }
  if (num >= 1000) {
    return (num / 1000).toFixed(1) + '千'
  }
  return num.toString()
}

// 时间范围生成
export const generateTimeRange = (type) => {
  const now = new Date()
  const ranges = {
    'today': [new Date(now.setHours(0, 0, 0, 0)), now],
    'week': [new Date(now.setDate(now.getDate() - 7)), now],
    'month': [new Date(now.setMonth(now.getMonth() - 1)), now],
    'year': [new Date(now.setFullYear(now.getFullYear() - 1)), now]
  }
  return ranges[type] || [null, null]
}
